<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.org/thymeleaf/shiro">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>Title</title>
    <link rel="stylesheet" href="/resources/layui/css/layui.css">
</head>
<body>
<script src="/resources/layui/layui.js"></script>
<script type="text/javascript" src="/resources/js/jquery-1.12.3.min.js"></script>
<script th:inline="none">
    //一般直接写在一个js文件中
    layui.use(['layer', 'form','table'], function(){
        var layer = layui.layer
            ,form = layui.form
            ,table = layui.table
            ,$=layui.jquery;
        /*$("#confirm").click(function(){
            $.ajax({
                type:"post",
                url:"/vehiclefiles/addVehicle",
                data:$("#form1").serialize(),
                success:function(resp){
                    layer.msg(resp.message);
                    setTimeout(function(){
                        var index=parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);
                    },1000);
                }
            });
        });*/
        //品牌下拉菜单
        $.ajax({
            type:'get',
            url:'/dictionary/getbrand',
            success:function (res) {
                var carBrandList=res.data.carBrandList;
                if(carBrandList.length>0){
                    for(var i=0;i<carBrandList.length;i++){
                        var carBrand=carBrandList[i];
                        $("#brandid").append("<option value='"+carBrand.id+"'>"+carBrand.name+"</option>")
                    }
                }
                //渲染下拉菜单
                layui.form.render("select")
            }
        });
        //级别下拉菜单
        $.ajax({
            type:'get',
            url:'/dictionary/getclazz',
            success:function (res) {
                var carClazzList=res.data.carClazzList;
                if(carClazzList.length>0){
                    for(var i=0;i<carClazzList.length;i++){
                        var carClazz=carClazzList[i];
                        $("#clazzid").append("<option value='"+carClazz.id+"'>"+carClazz.name+"</option>")
                    }
                }
                //渲染下拉菜单
                layui.form.render("select")
            }
        });
        //型号下拉菜单
        $.ajax({
            type:'get',
            url:'/dictionary/gettype',
            success:function (res) {
                var carTypeList=res.data.carTypeList;
                if(carTypeList.length>0){
                    for(var i=0;i<carTypeList.length;i++){
                        var carType=carTypeList[i];
                        $("#typeid").append("<option value='"+carType.id+"'>"+carType.name+"</option>")
                    }
                }
                //渲染下拉菜单
                layui.form.render("select")
            }
        });
        //颜色下拉菜单
        $.ajax({
            type:'get',
            url:'/dictionary/getcolor',
            success:function (res) {
                var carColorList=res.data.carColorList;
                if(carColorList.length>0){
                    for(var i=0;i<carColorList.length;i++){
                        var carColor=carColorList[i];
                        $("#colorid").append("<option value='"+carColor.id+"'>"+carColor.name+"</option>")
                    }
                }
                //渲染下拉菜单
                layui.form.render("select")
            }
        });
        //部门下拉菜单
        $.ajax({
            type:'get',
            url:'/dept/getdept',
            success:function (res) {
                var deptList=res.data.deptList;
                if(deptList.length>0){
                    for(var i=0;i<deptList.length;i++){
                        var dept=deptList[i];
                        $("#did").append("<option value='"+dept.id+"'>"+dept.name+"</option>")
                    }
                }
                //渲染下拉菜单
                layui.form.render("select")
            }
        });
        //车辆状态下拉菜单
        $.ajax({
            type:'get',
            url:'/dictionary/getCarStatus',
            success:function (res) {
                var carStatusList=res.data.carStatusList;
                if(carStatusList.length>0){
                    for(var i=0;i<carStatusList.length;i++){
                        var carStatus=carStatusList[i];
                        $("#statusid").append("<option value='"+carStatus.id+"'>"+carStatus.name+"</option>")
                    }
                }
                //渲染下拉菜单
                layui.form.render("select")
            }
        });
    });
    var addcallbackdata=function(){
        var forms = $("#form1").serialize();
        return forms;
    }
</script>
<form class="layui-form" action="" id="form1">
    <div class="layui-form-item">
        <label class="layui-form-label">车牌号：</label>
        <div class="layui-input-block">
            <input type="text" name="vehiclenum" required  lay-verify="required" placeholder="请输入车牌号" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">品牌：</label>
        <div class="layui-input-block">
            <select id="brandid" name="brand" lay-verify="required">
                <option value="0">请选择车辆品牌</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">级别：</label>
        <div class="layui-input-block">
            <select id="clazzid" name="clazz" lay-verify="required">
                <option value="0">请选择车辆级别</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">型号：</label>
        <div class="layui-input-block">
            <select id="typeid" name="type" lay-verify="required">
                <option value="0">请选择车辆型号</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">颜色：</label>
        <div class="layui-input-block">
            <select id="colorid" name="color" lay-verify="required">
                <option value="0">请选择车辆颜色</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">座位数：</label>
        <div class="layui-input-block">
            <input type="text" name="seat" required  lay-verify="required" placeholder="请输入座位数" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">部门：</label>
        <div class="layui-input-block">
            <select id="did" name="did" lay-verify="required">
                <option value="0">请选择车辆部门</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">购买日期：</label>
        <div class="layui-input-inline">
            <input type="Date" name="purchasedate" required lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">
        </div>

    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">车辆状态：</label>
        <div class="layui-input-block">
            <select id="statusid" name="carstatus" lay-verify="required">
                <option value="0">请选择车辆状态</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">状态：</label>
        <div class="layui-input-block">
            <input type="radio" name="available" value="1" title="启用"  checked>
            <input type="radio" name="available" value="0" title="禁用">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>

</body>
</html>